/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package idea.apptopcomponents;


import idea.countries.CountryTopComponent;
import idea.de.explorer.IDataElemsTopComponent;
import idea.icci.explorer.CustomContentItemsTopComponent;
import idea.ipreview.IPreviewTopComponent;
import idea.iqtitles.explorer.IQuestionTitleTopComponent;
import idea.iquest.explorer.IQuestionnairesTopComponent;
import idea.model.powersearch.CCISearchResultsTopComponent;
import idea.model.powersearch.QTSearchResultsTopComponent;
import idea.sfo.viewer.SfoViewerTopComponent;
import org.esakk001.MainTopComponent;
import org.openide.windows.WindowManager;
import org.shop.editor.UserEditorTopComponent;
import org.shop.viewer.UserViewerTopComponent;


/**
 * Class of all top component windows grouped together,
 * mostly for easy access by each other, and by Clear on Opening TC (not here)
 *
 * @author rejun001
 */
public class AppTopComponents
{
     
    // CRUDS for main app
    private IQuestionnairesTopComponent qnrTC = null;
    private IQuestionTitleTopComponent qtTC = null;
    private CustomContentItemsTopComponent cciTC = null;
    private IDataElemsTopComponent deTC = null;

    // SFO and jpeg rendering TCs
    private SfoViewerTopComponent treeTC = null;
    private IPreviewTopComponent prevTC = null;

    // Power search TCs
    private QTSearchResultsTopComponent qtsrTC = null;
    private CCISearchResultsTopComponent ccisrTC = null;
    
    // One-off CRUD TCs
    private UserViewerTopComponent uvTC = null;  // Russ -- Users
    private UserEditorTopComponent ueTC = null;  // Russ - Users
    private MainTopComponent maTC = null;        // Ramesh -- multiple

    // Misc designer 
    //private ShapeTopComponent shapeTC = null;
    private CountryTopComponent cdTC = null;

    // Multiple one-off CRUD TC
    //private MultiCrudTopComponent multiTC = null;


    /**
     * simple Class Constructor
     */
    public AppTopComponents()
    {

        if ( qnrTC == null )
        {
            qnrTC = (IQuestionnairesTopComponent) WindowManager.getDefault()
                    .findTopComponent( "IQuestionnairesTopComponent" );
        }
        if ( qtTC == null )
        {
            qtTC = (IQuestionTitleTopComponent) WindowManager.getDefault()
                    .findTopComponent( "IQuestionTitleTopComponent" );
        }
        if ( cciTC == null )
        {
            cciTC = (CustomContentItemsTopComponent) WindowManager.getDefault()
                    .findTopComponent( "CustomContentItemsTopComponent" );
        }
        if ( deTC == null )
        {
            deTC = (IDataElemsTopComponent) WindowManager.getDefault()
                    .findTopComponent( "IDataElemsTopComponent" );
        }
        if ( treeTC == null )
        {
            treeTC = (SfoViewerTopComponent) WindowManager.getDefault()
                    .findTopComponent( "SfoViewerTopComponent" );
        }
        if ( prevTC == null )
        {
            prevTC = (IPreviewTopComponent) WindowManager.getDefault()
                    .findTopComponent( "IPreviewTopComponent" );
        }
        if ( cdTC == null )
        {
            cdTC = (CountryTopComponent) WindowManager.getDefault()
                    .findTopComponent( "CountryTopComponent" );
        }
//        if ( shapeTC == null )
//        {
//            shapeTC = (ShapeTopComponent) WindowManager.getDefault()
//                    .findTopComponent( "ShapeTopComponent" );
//        }
        if ( qtsrTC == null )
        {
            qtsrTC = (QTSearchResultsTopComponent) WindowManager.getDefault()
                    .findTopComponent( "QTSearchResultsTopComponent" );
        }
        if ( ccisrTC == null )
        {
            ccisrTC = (CCISearchResultsTopComponent) WindowManager.getDefault()
                    .findTopComponent( "CCISearchResultsTopComponent" );
        }
        if (uvTC == null) {
            uvTC = (UserViewerTopComponent) WindowManager.getDefault()
                    .findTopComponent( "UserViewerTopComponent" );
        }
        if (ueTC == null) {
            ueTC = (UserEditorTopComponent) WindowManager.getDefault()
                    .findTopComponent( "UserEditorTopComponent" );
        }
        if (maTC == null) {
            maTC = (MainTopComponent) WindowManager.getDefault()
                    .findTopComponent( "MainTopComponent" );
        }

    }


    public CountryTopComponent getCdTC()
    {
        return cdTC;
    }


//    public ShapeTopComponent getShapeTC()
//    {
//        return shapeTC;
//    }


//    public OpeningEditorTopComponent getOeTC()
//    {
//        return oeTC;
//    }
    public IQuestionnairesTopComponent getQnrTC()
    {
        return qnrTC;
    }


    public IQuestionTitleTopComponent getQtTC()
    {
        return qtTC;
    }


    public CustomContentItemsTopComponent getCciTC()
    {
        return cciTC;
    }


    public IDataElemsTopComponent getDeTC()
    {
        return deTC;
    }

    public IPreviewTopComponent getPrevTC()
    {
        return prevTC;
    }


    public void setPrevTC( IPreviewTopComponent prevTC )
    {
        this.prevTC = prevTC;
    }


    public QTSearchResultsTopComponent getQtsrTC()
    {
        return qtsrTC;
    }


    public void setQtsrTC( QTSearchResultsTopComponent qtsrTC )
    {
        this.qtsrTC = qtsrTC;
    }


    public CCISearchResultsTopComponent getCcisrTC()
    {
        return ccisrTC;
    }


    public void setCcisrTC( CCISearchResultsTopComponent ccisrTC )
    {
        this.ccisrTC = ccisrTC;
    }


    public UserViewerTopComponent getUvTC()
    {
        return uvTC;
    }


    public void setUvTC( UserViewerTopComponent uvTC )
    {
        this.uvTC = uvTC;
    }


    public UserEditorTopComponent getUeTC()
    {
        return ueTC;
    }


    public void setUeTC( UserEditorTopComponent ueTC )
    {
        this.ueTC = ueTC;
    }


    public MainTopComponent getMaTC()
    {
        return maTC;
    }


    public void setMaTC( MainTopComponent maTC )
    {
        this.maTC = maTC;
    }


    public SfoViewerTopComponent getTreeTC()
    {
        return treeTC;
    }
    
    public void closeCrudTCs()
    {
        if ( qnrTC != null )
        {
            qnrTC.close();
        }
        if ( qtTC != null )
        {
            qtTC.close();
        }
        if ( cciTC != null )
        {
            cciTC.close();
        }
        if ( deTC != null )
        {
            deTC.close();
        }

    }


    public void closeSfoTCs()
    {
        if ( treeTC != null )
        {
            treeTC.close();
        }
        if ( prevTC != null )
        {
            prevTC.close();
        }
    }

    public void closeSearchTCs()
    {
        if ( qtsrTC != null )
        {
            qtsrTC.close();
        }
        if ( ccisrTC != null )
        {
            ccisrTC.close();
        }
        if ( qnrTC != null )
        {
            qnrTC.close();
        }
    }

    public void closeDesignerTCs()
    {
        if ( cdTC != null )
        {
            cdTC.close();
        }
//        if ( shapeTC != null )
//        {
//            shapeTC.close();
//        }

    }
    
    public void closeOneOffTcs() 
    {
        if (ueTC != null) {
            ueTC.close();
        }
        if (uvTC != null) {
            uvTC.close();
        }
        if (maTC != null) {
            maTC.close();
        }
    }

}
